<?php
set_time_limit(0);

include_once "imagetool.php";


header("Content-Type:text/html;charset=utf-8");


$configs=array(
		"markWordsPosition"=>9,"xyOffsets"=>array(-12,-12),
		"markWordsWidth"=>0,"markWordsHeight"=>0,"markWordsAngle"=>0,
		"font"=>"huakang_girl_w5.ttf","fontSize"=>14,"fontColor"=>"#000000",
		"addShadow"=>1,"shadowColor"=>"#ffffff",
		"markImagePosition"=>5,"xyOffsets2"=>array(0,0),
		"markImageWidthRequired"=>0,"markImageHeightRequired"=>0
	);//huakang_girl_w5.ttf    myfont.ttf

$mark_words = "webdev.brunoxu.info";//"webdev.brunoxu.info"

$waterpaper = "";//"waterpaper.png"


$src_path = 'D:/image/宠物/2012.09.26/宠物兔子/';
$tar_path = 'D:/image/宠物/2012.09.26/宠物兔子/result/';

$is_win_and_cnchar = true;
//Win+两中文目录:true->OK
//Win+两英文目录:true->OK false->OK
//Linux+两中文目录:false->NG true->OK(有可能flashfxp里建目录就是gbk编码的中文？果然通过cPanel登录后查看时乱码，改成utf-8中文名后变成了false->NG true->NG，false时还有错和在取图片列表时转换了文件名字编码有关，根本原因还是linux下str_to_utf8函数中的检测编码不准，所以改造了get_images函数)
//Linux+两英文目录:false->OK true->OK

if ($is_win_and_cnchar) {
	$tar_path_gbk = mb_convert_encoding($tar_path, "GBK", "UTF-8");
	if(!is_dir($tar_path_gbk)) {
		mkdir($tar_path_gbk, 0777);
	}
} else {
	if(!is_dir($tar_path)) {
		mkdir($tar_path, 0777);
	}
}


if ($is_win_and_cnchar) {
	$imgs = imagetool::get_images(mb_convert_encoding($src_path, "GBK", "UTF-8"), FALSE, $is_win_and_cnchar);
} else {
	$imgs = imagetool::get_images($src_path, FALSE, $is_win_and_cnchar);
}


foreach ($imgs as $img) {
	$im = $img;
	$nim = $tar_path.filetooltiny::get_filename_from_filepath($img);

	echo $im." -> ";

	if ($is_win_and_cnchar) {
		$im = mb_convert_encoding($im, "GBK", "UTF-8");
		$nim = mb_convert_encoding($nim, "GBK", "UTF-8");
	}

	if (imagetool::resize_image_ex(
			$im,$nim
			,1024,768
			,$mark_words,$waterpaper,
			TRUE,FALSE,FALSE,
			100,(1024*100),70,
			$configs
		)) {
		echo "success<br/>";
	} else {
		echo "failure<br/>";
	}
}

?>